<template>
  <el-table
    :data="list"
    border
    style="width: 100%"
    cell-class-name="align-c"
    table-layout="auto"
  >
    <el-table-column prop="id" label="编号" />
    <el-table-column prop="name" label="资源名称" />
    <el-table-column prop="url" label="资源路径" />
    <el-table-column prop="description" label="描述" />
    <el-table-column prop="createTime" label="添加时间">
      <template #default="{ row }">
        <span>{{ formateDate(row.createTime) }}</span>
      </template>
    </el-table-column>
  </el-table>
  <ElConfigProvider :locale="zhCn">
    <div class="page">
      <el-pagination
        v-model:current-page="pageNum"
        v-model:page-size="pageSize"
        :page-sizes="[10, 20, 50, 100]"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
        @size-change="pageSizeChangeHandle"
        @current-change="pageChangeHandle"
      />
    </div>
  </ElConfigProvider>
</template>
<script setup lang="ts">
import useTable from "@/hooks/useTable";
import { resourceListApi } from "./api";
import { ElConfigProvider } from "element-plus";
import zhCn from "element-plus/lib/locale/lang/zh-cn";
import { formateDate } from "@/utils";

const {
  list,
  pageNum,
  pageSize,
  total,
  pageChangeHandle,
  pageSizeChangeHandle,
} = useTable(resourceListApi);
</script>
<style lang="less" scoped>
:deep(.align-c) {
  .cell {
    text-align: center !important;
  }
}
.page {
  display: flex;
  justify-content: right;
  padding-top: 20px;
}
</style>
